package com.labreeze.spring.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.labreeze.spring.dao.DaoTest;
import com.labreeze.spring.pojo.User;
import com.labreeze.spring.service.UserService;


@Controller
@RequestMapping("/")
public class IndexController {
	@Autowired
	private UserService userService;
	
	@RequestMapping("index")
	public String index(){
		return "index";
	}
	
	
	@RequestMapping("test")
	public String test(){
		return "test";
	}
	
	@RequestMapping("{id}")
	public String test2(@PathVariable("id") int id,Model map){
		Logger.getLogger(IndexController.class).error("test");
		User user=userService.findById(id);
		map.addAttribute("user", user);
		return "test2";
	}
	

}
